package com.xiaoma.myaudience.biz.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;

import com.xiaoma.myaudience.R;
import com.xiaoma.myaudience.biz.app.AudienceApplication;
import com.xiaoma.myaudience.biz.util.Constant;
import com.xiaoma.myaudience.util.NetUtils;
import com.xiaoma.myaudience.util.activity.BaseActivity;

public class ForgetPasswordActivity extends BaseActivity {

	private Context mContext;
	
	private WebView mForgetPasswordWebview;
    private LinearLayout mLoaddingLayout;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    	 super.onCreate(savedInstanceState);
         setContentView(R.layout.personal_forget_password);
         
         setNetEaseTitleBarVisibility(View.VISIBLE);
         setNetEaseTitle(R.string.str_forget_password_title);
         setNetEaseTitleGravity(Gravity.CENTER);
         
         mContext = this;
         
         findViewsById();
         setlayoutClickListener();
         mLoaddingLayout.setVisibility(View.VISIBLE);
         ((AudienceApplication)getApplication()).postExe(new Runnable() {
 			
 			@Override
 			public void run() {
 				mForgetPasswordWebview.loadUrl(Constant.URL_FORGETPASSWORD_PATH);
 			}
 		});
         
    }
    
    private void findViewsById() {
    	mForgetPasswordWebview = (WebView)findViewById(R.id.web_forget_password_view);
    	mLoaddingLayout = (LinearLayout) findViewById(R.id.lin_commen_loadding);
        
     }
    
    /**设置组件监听动作*/
	private void setlayoutClickListener() {
		
		mForgetPasswordWebview.getSettings().setJavaScriptEnabled(true);
		mForgetPasswordWebview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
		if(NetUtils.isCMWAP(mContext))
			WebView.enablePlatformNotifications();
		
		mForgetPasswordWebview.setWebViewClient(new WebViewClient(){
			
			@Override
			public void onPageFinished(WebView view, String url) {
				// TODO Auto-generated method stub
				
				mLoaddingLayout.setVisibility(View.GONE);
				super.onPageFinished(view, url);
			}
		});
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if(NetUtils.isCMWAP(mContext)){
			if(null!=mForgetPasswordWebview){
				WebView.disablePlatformNotifications();
			}
		}
	}
}
